Trees should be an essential, rather than merely a desirable part of our cities (Ely, Martin, 2009). Street trees provide the city with a wide range of benefits: a friendly environment and a clean atmosphere for humans and animals. The city should compose a habitable environment for the trees. Providing the conditions to grow healthy, long-lived trees is the best approach to minimize the conflicts between trees and the surrounding urban infrastructure. In this analysis, I am going to talk about street trees in the City of Vancouver, and see their distribution of the type, location, and other characteristics to determine if each of the areas is surrounded by trees diversified and if it gives some insight into the area infrastructure in the city environment. I hope my analysis helps some businesses to gain some insightful ideas, and so it ultimately leads to the result of better urban city development and planning for the community.
The original data were obatained from the City of Vancouver's Open Data Portal and follows as City of Vancouver Open Data Portal > Streets and Transportation > Street trees.
UBC Data Science faculty has done of wrangling and cleaning for the origianl dataset, and provided with a modified version of the dataset. The subset of the original data may or may not be a representative sample of the original data set.
The street_trees dataset is a table composed of 21 columns, Unnamed: 0, std_street, on_street, species_name, neighbourhood_name, date_planted, diameter, street_side_name, genus_name, assigned, civic_number, plant_area, curb, tree_id, height_range_id, on_street_block, cultivar_name, root_barrier, latitude, longitude stored in a .csv file.
The following columns are the dataset schema:
In this study, data visualization methods and techniques were conducted to analyze the information in street_trees dataset.
Cities around the world are looking for ways to improve the livability of their cities and street trees are a common and important remedy for urban planning departments. Street trees can improve aspects of city life like air quality, biodiversity, and various beneficial health outcomes. Cities can improve their quality of life by adding trees and other foliage along the side of their roads (UBC Open Case Studies).
# Import all the required libraries needed for EDA.
import pandas as pd
import numpy as np
import altair as alt
#!conda install -c conda-forge folium=0.5.0 --yes
import folium
# Import the street trees dataset.
street_trees = pd.read_csv("https://raw.githubusercontent.com/UBC-MDS/data_viz_wrangled/main/data/Trees_data_sets/small_unique_vancouver.csv").dropna()
street_trees.head()
| Unnamed: 0 | std_street | on_street | species_name | neighbourhood_name | date_planted | diameter | street_side_name | genus_name | assigned | ... | plant_area | curb | tree_id | common_name | height_range_id | on_street_block | cultivar_name | root_barrier | latitude | longitude | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 12573 | W 18TH AV | W 18TH AV | CALLERYANA | Arbutus-Ridge | 1992-02-04 | 6.0 | ODD | PYRUS | N | ... | 7 | Y | 129645 | CHANTICLEER PEAR | 2 | 2300 | CHANTICLEER | N | 49.256350 | -123.158709 |
| 3 | 8856 | DOMAN ST | DOMAN ST | AMERICANA | Killarney | 1999-11-12 | 11.0 | EVEN | FRAXINUS | N | ... | 7 | Y | 180803 | AUTUMN APPLAUSE ASH | 4 | 6900 | AUTUMN APPLAUSE | N | 49.220839 | -123.036721 |
| 5 | 17458 | BUTE ST | BUTE ST | PERSICA | West End | 2012-04-05 | 3.0 | EVEN | PARROTIA | N | ... | C | Y | 233622 | VANESSA PERSIAN IRONWOOD | 1 | 1100 | VANESSA | N | 49.281906 | -123.133076 |
| 9 | 28279 | MATAPAN CRESCENT | MATAPAN CRESCENT | ZUMI | Renfrew-Collingwood | 2008-03-13 | 3.0 | ODD | MALUS | N | ... | 12 | Y | 102612 | REDBUD CRABAPPLE | 1 | 3200 | CALOCARPA | Y | 49.257272 | -123.030023 |
| 10 | 1684 | KINGSWAY | KINGSWAY | SYLVATICA | Kensington-Cedar Cottage | 2009-11-06 | 3.0 | MED | FAGUS | N | ... | 8 | Y | 228772 | DAWYCK'S BEECH | 1 | 1500 | DAWYCKII | N | 49.248839 | -123.073073 |
5 rows × 21 columns
# Information of the data frame in the dataset.
street_trees.info()
<class 'pandas.core.frame.DataFrame'> Int64Index: 1653 entries, 1 to 4997 Data columns (total 21 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Unnamed: 0 1653 non-null int64 1 std_street 1653 non-null object 2 on_street 1653 non-null object 3 species_name 1653 non-null object 4 neighbourhood_name 1653 non-null object 5 date_planted 1653 non-null object 6 diameter 1653 non-null float64 7 street_side_name 1653 non-null object 8 genus_name 1653 non-null object 9 assigned 1653 non-null object 10 civic_number 1653 non-null int64 11 plant_area 1653 non-null object 12 curb 1653 non-null object 13 tree_id 1653 non-null int64 14 common_name 1653 non-null object 15 height_range_id 1653 non-null int64 16 on_street_block 1653 non-null int64 17 cultivar_name 1653 non-null object 18 root_barrier 1653 non-null object 19 latitude 1653 non-null float64 20 longitude 1653 non-null float64 dtypes: float64(3), int64(5), object(13) memory usage: 284.1+ KB
# The description of the data.
street_trees.describe()
| Unnamed: 0 | diameter | civic_number | tree_id | height_range_id | on_street_block | latitude | longitude | |
|---|---|---|---|---|---|---|---|---|
| count | 1653.000000 | 1653.000000 | 1653.000000 | 1653.000000 | 1653.000000 | 1653.000000 | 1653.000000 | 1653.000000 |
| mean | 14689.987296 | 6.004864 | 3106.491833 | 174940.944949 | 1.736237 | 3146.400484 | 49.245937 | -123.101320 |
| std | 8778.890359 | 3.880239 | 2155.172608 | 59039.081620 | 0.887429 | 2183.920864 | 0.021302 | 0.048578 |
| min | 2.000000 | 1.000000 | 3.000000 | 616.000000 | 0.000000 | 0.000000 | 49.203531 | -123.220360 |
| 25% | 6907.000000 | 3.000000 | 1365.000000 | 150798.000000 | 1.000000 | 1400.000000 | 49.228664 | -123.137163 |
| 50% | 14579.000000 | 4.500000 | 2728.000000 | 184692.000000 | 2.000000 | 2700.000000 | 49.245210 | -123.099031 |
| 75% | 22253.000000 | 8.000000 | 4472.000000 | 222708.000000 | 2.000000 | 4500.000000 | 49.262586 | -123.059325 |
| max | 29979.000000 | 31.000000 | 8989.000000 | 262098.000000 | 6.000000 | 8600.000000 | 49.292581 | -123.023514 |
# The shape of the data frame.
street_trees.shape
(1653, 21)
Street trees can improve the livability of cities in many different ways. In its lifetime a tree provides us with many benefits. In recent years the idea of street trees have became a popular idea, therefore more people are recognizing the need for it. The street trees have to be the default design for our streets.
Let's dive into the street_trees dataset, and discover the varieties of the public trees on boulevards in the City of Vancouver.
# Top 10 tree species in the City of Vancouver.
tree_bar = alt.Chart(street_trees).transform_aggregate(
count='count()',
groupby=['species_name']
).transform_window(
rank='rank(count)',
sort=[alt.SortField('count', order='descending')]
).transform_filter(
alt.datum.rank <= 10
).mark_bar().encode(
y=alt.Y('species_name:N', sort='-x'),
x='count:Q',
color=alt.Color('species_name', scale=alt.Scale(scheme='category10'), sort=['PLATANOIDES','RUBRUM','CERASIFERA','FREEMANI X','BETULUS','SYLVATICA','X YEDOENSIS','CALLERYANA','SERRULATA','AMERICANA'])
).properties(title="Top 10 tree species in the City of Vancouver")
curbs = sorted(street_trees['curb'].unique())
radiobuttons_curbs = alt.binding_radio(name='Curbs ', options=curbs)
select_radio = alt.selection_single(
fields=['curb'],
bind={'curb': radiobuttons_curbs})
tree_bar = tree_bar.add_selection(select_radio).encode(
opacity=alt.condition(select_radio, alt.value(0.7), alt.value(0.05)))
tree_bar
In the city of Vancouver, Platanioides(183) holds the highest number of planted trees throughout the region, followed by Rubrum(142) and Cerasifera(115).
Platanoides, commonly known as the Norway maple, is a species of maple native. It is introduced to North America in the mid-1700s from Eurasia as an ornamental tree. They are widely available from nurseries and occur in southern British Columbia, and from southern Ontario east to Newfoundland (Tree Canada).
Image 1
Next, we would like to see the distribution of trees for each neighborhood in the city of Vancouver.
# The distribution of trees in Vancouver's neighborhood.
trees_count_neighbourhood = alt.Chart(street_trees).mark_bar().encode(
alt.X('neighbourhood_name', sort='-y', title='Neighbourhoods'),
alt.Y('count()', title='Number of trees')
).properties(title="The number of trees for each neighborhoods", width=700, height=200)
trees_count_neighbourhood + trees_count_neighbourhood.mark_text(align='center', dy=-7).encode(text=alt.Text('count(neighbourhood_name)'))
Renfrew-Collingwood is primarily a residential area, with good access to nature. Renfrew Ravine Park, which features a natural creek in the Still Creek watershed, is a lovely place to take a walk. Residents have easy access to services and amenities, especially along the Collingwood stretch of Kingsway. Renfrew-Collingwood runs along the city's east boundary with Burnaby (Area of the city).
Let's discover more about the top 10 tree species in the City of Vancouver.
top10_tree = street_trees.loc[street_trees['species_name']
.isin(['PLATANOIDES','RUBRUM','CERASIFERA','FREEMANI X','BETULUS','SYLVATICA','X YEDOENSIS','CALLERYANA','SERRULATA','AMERICANA'])
]
top10_tree.head()
| Unnamed: 0 | std_street | on_street | species_name | neighbourhood_name | date_planted | diameter | street_side_name | genus_name | assigned | ... | plant_area | curb | tree_id | common_name | height_range_id | on_street_block | cultivar_name | root_barrier | latitude | longitude | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 12573 | W 18TH AV | W 18TH AV | CALLERYANA | Arbutus-Ridge | 1992-02-04 | 6.0 | ODD | PYRUS | N | ... | 7 | Y | 129645 | CHANTICLEER PEAR | 2 | 2300 | CHANTICLEER | N | 49.256350 | -123.158709 |
| 3 | 8856 | DOMAN ST | DOMAN ST | AMERICANA | Killarney | 1999-11-12 | 11.0 | EVEN | FRAXINUS | N | ... | 7 | Y | 180803 | AUTUMN APPLAUSE ASH | 4 | 6900 | AUTUMN APPLAUSE | N | 49.220839 | -123.036721 |
| 10 | 1684 | KINGSWAY | KINGSWAY | SYLVATICA | Kensington-Cedar Cottage | 2009-11-06 | 3.0 | MED | FAGUS | N | ... | 8 | Y | 228772 | DAWYCK'S BEECH | 1 | 1500 | DAWYCKII | N | 49.248839 | -123.073073 |
| 15 | 5416 | GOTHARD ST | CLARENDON ST | PLATANOIDES | Renfrew-Collingwood | 1994-11-08 | 3.0 | EVEN | ACER | Y | ... | 8 | Y | 156303 | GLOBEHEAD NORWAY MAPLE | 2 | 4700 | GLOBOSUM | N | 49.241778 | -123.054438 |
| 19 | 17945 | W 12TH AV | W 12TH AV | SERRULATA | Kitsilano | 2008-03-13 | 9.0 | ODD | PRUNUS | N | ... | 20 | Y | 106587 | SHIROTAE(MT FUJI) CHERRY | 1 | 2600 | SHIROTAE | N | 49.261319 | -123.164948 |
5 rows × 21 columns
# The characteristics of the top 10 tree species.
tree_point = alt.Chart(top10_tree, width=700, height=500).mark_circle(size=40).encode(
alt.X('diameter', title='Diameter (inches)'),
alt.Y('height_range_id', title='Height range (*10 feet)'),
alt.Color('species_name', title="Species", scale=alt.Scale(scheme='category10'), sort=['PLATANOIDES','RUBRUM','CERASIFERA','FREEMANI X','BETULUS','SYLVATICA','X YEDOENSIS','CALLERYANA','SERRULATA','AMERICANA']),
tooltip=['species_name']
).properties(title="The characteristics of the top 10 tree species")
types = sorted(top10_tree['species_name'].unique())
dropdown = alt.binding_select(name='Genre ', options=types)
select_types = alt.selection_single(fields=['species_name'], bind=dropdown)
tree_point = tree_point.add_selection(select_types).encode(
opacity=alt.condition(select_types, alt.value(0.7), alt.value(0.05)))
tree_point
Let's create a point map which is one of the simplest ways to visualize geospatial data. Basically, we are going to place a point at each area on the map that corresponds to the street trees.
# Map visualization: Vancouver Street Trees Map
vancouver_location = [49.246292, -123.116226]
geo_json = "https://raw.githubusercontent.com/blackmad/neighborhoods/master/vancouver.geojson"
trees_map = folium.Map(
location = vancouver_location,
zoom_start = 12,
max_zoom=14,
min_zoom=12,
tiles = "Stamenterrain"
)
data_choropleth = street_trees['neighbourhood_name'].value_counts().reset_index().rename(columns={"index":"neighbourhood", "neighbourhood_name":"count"})
trees_map.choropleth(
geo_data=geo_json,
name="choropleth",
data=data_choropleth,
columns=['neighbourhood', 'count'],
key_on="feature.properties.name",
fill_color="YlGn",
fill_opacity=0.5,
line_opacity=0.4,
legend_name="Number of Trees (Count)"
)
for idx, rows in street_trees.iterrows():
if rows["species_name"] == "PLATANOIDES":
icon_color="#17becf",
elif rows["species_name"] == "RUBRUM":
icon_color="#ffbb78"
elif rows["species_name"] == "CERASIFERA":
icon_color="#c49c94"
elif rows["species_name"] == "FREEMANI X":
icon_color="#9edad5"
elif rows["species_name"] == "BETULUS":
icon_color="#d62728"
elif rows["species_name"] == "SYLVATICA":
icon_color="#d62728"
elif rows["species_name"] == "X YEDOENSIS":
icon_color="#bcbd22"
elif rows["species_name"] == "CALLERYANA":
icon_color="#ff9896"
elif rows["species_name"] == "SERRULATA":
icon_color="#ff9896"
elif rows["species_name"] == "AMERICANA":
icon_color="#ff7f0e"
folium.features.CircleMarker(location=[rows["latitude"], rows["longitude"]],
radius=1,
popup=rows['species_name'] + ' on ' + rows['on_street'] + ' in ' + rows['neighbourhood_name'],
color=icon_color
).add_to(trees_map)
trees_map
In the city of Vancouver, Platanioides(183) holds the highest number of planted trees throughout the region, followed by Rubrum(142) and Cerasifera(115). Renfrew-Collingwood area has the most nature-friendly environment.
click = alt.selection_multi(fields=['species_name'], bind='legend')
brush = alt.selection_interval(resolve='intersect')
bar = tree_bar.encode(opacity=alt.condition(click, alt.value(0.9), alt.value(0.2))).add_selection(click)
point = tree_point.encode(color=alt.condition(brush, 'species_name', alt.value('lightgray'))).add_selection(brush)
bar & point